<h3 class="report-h">Personal Leaving Request</h3>
<?php 
if ($this->session->userdata('delete_success')) {
	echo $this->session->userdata('delete_success');
	$this->session->unset_userdata('delete_success');
}
?>
<table class="table table-bordered">
    <thead> 
        <tr class="success">
            <td colspan="2" style="text-align:center;">Leave Date</td>
            <td colspan="2" style="text-align:center;">Type of Leave</td>
            <td colspan="3" style="text-align:center;">Sub Type of Leave</td>
            <td colspan="2" style="text-align:center;">Status</td>
             <td>Action</td>
        </tr>
        <tr class="success">
        <td style="text-align:center;">Start_Date</td>
        <td style="text-align:center;">End_Date</td>
        <td style="text-align:center;">Annual</td>
        <td style="text-align:center;">Catch_Up</td>
        <td style="text-align:center;">Impossed</td>
        <td style="text-align:center;">Personal</td>
        <td style="text-align:center;">Special</td>
        <td style="text-align:center;">Pending</td>
        <td style="text-align:center;">Approved</td>
        <td style="text-align:center;">Edit & Delete</td>
    </tr>
    </thead>
    <tbody>
        <?php
        foreach($personal->result() as $rows){
            $startdate=$rows->start_date;
            $enddate=$rows->end_date;
            $type_leave=$rows->lea_id;
            $sub_leave=$rows->stl_id;
           $status=$rows->rcd_status;
           $staff_id=$rows->staff_id;
         //  $discript=$rows->description;
       echo ' <tr><td style="text-align:center;"> ';
         echo $startdate; 
         echo '</td>
                <td style="text-align:center;">'.$enddate.'</td>
                <td style="text-align:center;">';
         if( $type_leave==1){
                $annual = $rows->duration;
                echo $annual;
            }else{
                echo '&nbsp;';
            }
         echo'</td><td style="text-align:center;">';
          if( $type_leave==2){
                $catch_up = $rows->duration;
                echo $catch_up;
            }else{
                echo '&nbsp;';
            }
         echo'</td><td style="text-align:center;">';
         if( $sub_leave==1){
                $impossed = $rows->duration;
                echo $impossed;
            }else{
                echo '&nbsp;';
            }
         echo '</td><td style="text-align:center;">';
         if( $sub_leave==2){
                $personal = $rows->duration;
                echo $personal;
            }else{
                echo '&nbsp;';
            }
         echo '</td><td style="text-align:center;">';
          if( $sub_leave==3){
                $special= $rows->duration;
                echo $special;
            }else{
                echo '&nbsp;';
            }
         echo '</td><td style="text-align:center;">';
         if( $status==0){
                $pending= $rows->duration;
               
                echo img('bootstrap/images/notice.png', 'title="Approved"');
            }else{
                echo '&nbsp;';
            }
         echo '</td><td style="text-align:center;">';
         if( $status==1){
              echo img('bootstrap/images/tick.png', 'title="Approved"');
            }else{
                echo '&nbsp;';
            }

           echo ' 
         </td>
         <td style="text-align:center;">';
        $edit = img('bootstrap/images/edit.gif');
	$del = img('bootstrap/images/del.png');
	$del_annual = anchor('staff/delete_before_approve/' . $rows->lea_id . '/' . $rows->rcd_id, $del, 'title="Delete" onclick="return confirm(\'Are you sure want to cancel this request?\');"');
	$del_catchup = anchor('staff/delete_before_approve/' . $rows->lea_id . '/' . $rows->rcd_id . '/' . $rows->desc_id, $del, 'title="Delete" onclick="return confirm(\'Are you sure want to cancel this request?\');"');
	$edit_annual = anchor('staff/update_before_approve/' . $rows->lea_id . '/' . $rows->rcd_id, $edit, 'title="Edit"');
	$edit_catchup = anchor('staff/update_before_approve/' . $rows->lea_id . '/' . $rows->rcd_id . '/' . $rows->desc_id, $edit, 'title="Edit"');
	if ($status==0) {
            if($type_leave==1){
                echo $edit_annual . ' | ' . $del_annual;
        
            }else{
                echo $edit_catchup.' | '.$del_catchup;
            }
	} else{
	echo '&nbsp;';
	}
    echo '    
</td>
</tr>';
         }
        ?>
        <tr>
            <td colspan="2" >Sub Total</td>
           
            <td style="text-align:center;" >
         <?php
            $annul=0;
            $catch_up=0;
            $imposs=0;
            $person=0;
            $spec=0;
            $pen=0;
            $ann=0;
             foreach($query->result() as $rows){
                    $type_id=$rows->lea_id;
                        $sub_leave=$rows->stl_id;
                        $status=$rows->rcd_status;
			$id=$rows->duration;
			
			if($type_id==1){
				$annul=$id+$annul;
			}else if($type_id==2){
				$catch_up=$id+$catch_up;
                	}
                        if($sub_leave==1){
                            $imposs=$id+$imposs;
                        }else if($sub_leave==2){
                            $person=$id+$person;
                        }else if($sub_leave==3){
                            $spec=$id+$spec;
                        }
                        if($status==0){
                            $pen=$id+$pen;
                        }else if($status==1){
                            $ann=$id+$ann;
                        }
                          
			
            
                }$totals=$annul+$catch_up;
            
            echo '<b style="color:red;">'.$annul.'</b> days';
		?></td>
            <td style="text-align:center;"><?php echo '<b style="color:red;">'.$catch_up.'</b> days';?></td>
            <td style="text-align:center;"><?php echo '<b style="color:red;">'.$imposs.'</b> days';?></td>
            <td style="text-align:center;"><?php echo '<b style="color:red;">'.$person.'</b> days';?></td>
            <td style="text-align:center;"><?php echo '<b style="color:red;">'.$spec.'</b> days';?></td>
            <td style="text-align:center;"><?php echo '<b style="color:red;">'.$pen.'</b> days';?></td>
            <td style="text-align:center;"><?php echo '<b style="color:red;">'.$ann.'</b> days';?></td>
            <td></td>
        </tr>
        <tr>
            <td colspan="2" >Total</td>
            <td colspan="8"><?php echo '<b style="color:red;">'.$totals.'</b> days';?></td>
           
        </tr>
    </tbody>
</table>